import type { RequestOption } from "../../index.js";
import { fields, Operation } from "./util.js";

export const setPages: RequestOption = {
    name: "0x02 设置窗口",
    description: "设置当前打开的窗口列表，这个接口的主要作用是用来激活变量列表",
    fields: [
        fields.op(Operation.SetPage),
        fields.crc,
        {
            name: "length",
            kind: "custom",
            cb(ctx) {
                let len = 0;
                for (const key in ctx.lengths) {
                    len += ctx.lengths[key]!;
                }
                return [len - 3];
            },
        },
        {
            name: "新打开的画面",
            kind: "list",
            value: [0x01, 0x00],
            sizeFormat: 1,
            step: 2,
        },
        {
            name: "开着的画面",
            kind: "list",
            value: [],
            sizeFormat: 0,
            step: 2,
        },
    ],
};
